﻿Public Class RoughnessForm


    Dim Func As Functions = New Functions

    Dim RoughnessName(100) As String
    Dim RoughnessValue(100) As Double
    Public Roughness As Double


    '起動時の挙動（Roughness.txtから，保存してある値を読み込んで表示）
    Private Sub RoughnessForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim path As String = "RoughnessInfo.txt"
        Dim Reader As IO.StreamReader = New IO.StreamReader(path)
        Dim Read As String
        Dim retval(10) As String
        Dim InfoCounter As Integer = 0

        While Not Reader.Peek = -1
            Read = Reader.ReadLine
            retval = Read.Split(CChar("/"))
            RoughnessName(InfoCounter) = retval(0)
            RoughnessValue(InfoCounter) = CDbl(retval(1))
            InfoCounter += 1
        End While

        ComboBoxRoughness.Items.Clear()

        For i As Integer = 0 To InfoCounter - 1
            ComboBoxRoughness.Items.Add(RoughnessName(i))
        Next

        Reader.Close()

    End Sub

    'OKボタンの挙動
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOK.Click
        Dim Index As Integer = ComboBoxRoughness.SelectedIndex
        Dim path As String = "Roughness.txt"
        Dim Writer As IO.StreamWriter = New IO.StreamWriter(path)

        Roughness = RoughnessValue(Index)

        Writer.Write(CStr(Roughness))

        Writer.Close()

        Me.Close()

    End Sub
End Class